home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / raster9 / raster9.asm < prev    next >
Encoding:
Assembly Source File  |  1992-09-13  |  13.1 KB  |  563 lines

  1. ;********************************
  2. pushreg    macro
  3.         push        ax
  4.         push             bx
  5.         push        cx
  6.         push             dx
  7.         endm
  8.  
  9. popreg    macro
  10.         pop         dx
  11.         pop         cx
  12.         pop         bx
  13.                 pop             dx
  14.         endm
  15.  
  16.  
  17. ;******************************************************************
  18. pile    segment    para        stack    'pile'         ;   définit
  19.         db        256        dup(0) ;      la
  20. pile    ends                                           ;     pile
  21. ;******************************************************************
  22.  
  23. ;******************************************************************
  24. donnees segment para            public 'donnees'
  25.  
  26. back db 64000 dup(?)          ; place pour image fond
  27.  
  28. ball:                         ; sprite ball
  29.  include c:\masm\data\ball.nda
  30.  
  31. donnees ends
  32. ;******************************************************************
  33.  
  34.  
  35. .286P
  36. code    segment para            public  'code'
  37.                 assume  cs:code, ss:pile, ds:code
  38.  
  39.  
  40. maitre:
  41.  
  42. ;                mov             dx,3d4h       ; Trident 128 ko Page
  43. ;                mov             ax,10*256+1fh
  44. ;                out             dx,ax
  45.  
  46.                 mov             ax,0013h      ; 320x200 256 Couleurs
  47.                 int             10h
  48.  
  49.              ;   mov             dx,3d4h       ; modulo page
  50.              ;   mov             ax,40*256+13h ; = Normal (40*8 plans = 320 oct)
  51.              ;   out             dx,ax
  52.  
  53.              ;   mov             dx,3c2h
  54.              ;   mov             al,11100011b  ; 0E3h
  55.              ;   out             dx,al         ; 60 hz
  56.  
  57.              ;   mov             dx,3d4h
  58.              ;   mov             ax,9          ; 320x400
  59.              ;   out             dx,ax
  60.  
  61.              ;   mov             dx,3d4h        ; 204 lignes
  62.              ;   mov             ax,156*256+12h
  63.              ;   out             dx,ax
  64.              ;   mov             ax,255*256+15h ; 208 lignes
  65.              ;   out             dx,ax
  66.  
  67.              ;   mov             dx,3d4h       ;??? Kronch ???
  68.              ;   mov             ax,200*256+14h
  69.              ;   out             dx,ax
  70.  
  71.  
  72.                ; Affiche Image et Initialise Palette
  73.                ;_____________________________________
  74.  
  75.                 mov ax,01012h
  76.                 xor bx,bx
  77.                 mov cx,256
  78.                 mov dx,cs
  79.                 mov es,dx
  80.                 lea dx,palet
  81.                 int 10h
  82.  
  83.                ;************* Load Picture **************
  84.                 mov ax,cs
  85.                 mov ds,ax
  86.                 mov ax,03d00h
  87.                 lea dx,image
  88.                 int 21h
  89.  
  90.                 mov bx,ax
  91.                 mov ah,03fh
  92.                 mov cx,64000
  93.                 mov dx,seg back
  94.                 mov ds,dx
  95.                 mov dx,offset back
  96.                 int 21h
  97.  
  98.                 mov ah,03eh
  99.                 int 21h
  100.  
  101.                 cld
  102.                 mov si,seg back      ; copy BackGround to Screen Memory
  103.                 mov ds,si
  104.                 mov si,offset back
  105.                 mov di,0a000h
  106.                 mov es,di
  107.                 xor di,di ;mov di,8*320
  108.                 mov cx,32000
  109.                 rep movsw
  110.  
  111.                 mov ax,cs
  112.                 mov ds,ax
  113.  
  114.                ;*****************************************
  115.  
  116.                 cli ;Int Off
  117.  
  118.                 mov ax,cs
  119.                 mov ds,ax
  120.                 mov ax,3508h     ;lire adr IRQ0
  121.                 int 21h
  122.                 mov timer,bx
  123.                 mov timer+2,es   ;sauver
  124.  
  125.                 mov ax,cs
  126.                 mov ds,ax
  127.                 mov ax,2508h     ;placer ma IRQ0
  128.                 lea dx,raster    ;ds=code
  129.                 int 21h
  130.  
  131.                 mov al,182        ;Timer : 15750 Khz
  132.                 out 43h,al
  133.                 mov al,76         ;1193180/15750=76
  134.                 out 40h,al
  135.                 xor al,al
  136.                 out 40h,al
  137.  
  138.                 mov al,11111110b  ;autorise only my IRQ0
  139.                 out 021h,al
  140.                 mov al,11111111b
  141.                 out 0a1h,al
  142.  
  143.                 mov si,cs      ; !!!!!!!
  144.                 mov ds,si      ; !!!!!!!
  145.                 lea si,colors_table
  146.                 mov pok,si
  147.  
  148.                 call wait_hbl
  149.  
  150.                 sti ;Int On
  151. main:
  152.  
  153.         call    wait_vbl
  154.  
  155. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  156.  
  157.         lea     si,colors_table
  158.         mov     pok,si
  159.  
  160.         cld
  161.  
  162.         mov di,cs              ; clear rasters page
  163.         mov es,di
  164.         lea di,colors_table
  165.         lea si,fond
  166.         mov cx,300*3/2
  167.         rep movsw
  168.  
  169.         mov ax,rolo_pt         ; pointeur sinus
  170.         add ax,2*2             ; incrément
  171.         and ax,1023
  172.         mov rolo_pt,ax
  173.  
  174.         lea bx,rolo_sin        ; prendre 1er sinus
  175.         add bx,ax
  176.         mov ax,[bx]
  177.      ;*********************************************
  178.         lea si,rolo1           ; affichage rouleaux
  179.         lea dx,colors_table    ; 1er rouleau
  180.         mov di,dx
  181.         add di,ax
  182.         mov cx,30*3/2
  183.         rep movsw
  184.  
  185.         rept 4
  186.  
  187.         add bx,32              ; autres rouleaux
  188.         mov ax,[bx]
  189.         mov di,dx
  190.         add di,ax
  191.         mov cx,30*3/2
  192.         rep movsw
  193.  
  194.         endm
  195.  
  196. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  197.  
  198.      ;   mov dx,3ceh
  199.      ;   mov ax,04005h
  200.      ;   out dx,ax
  201.      ;   mov ax,00104h
  202.      ;   out dx,ax
  203.  
  204.         mov ax,coord           ; clear balls
  205.         mov bx,coord+2
  206.         call clr_ball
  207.         mov ax,coord+4
  208.         mov bx,coord+6
  209.         call clr_ball
  210.         mov ax,coord+8
  211.         mov bx,coord+10
  212.         call clr_ball
  213.         mov ax,coord+12
  214.         mov bx,coord+14
  215.         call clr_ball
  216.         mov ax,coord+16
  217.         mov bx,coord+18
  218.         call clr_ball
  219.         mov ax,coord+20
  220.         mov bx,coord+22
  221.         call clr_ball
  222.         mov ax,coord+24
  223.         mov bx,coord+26
  224.         call clr_ball
  225.  
  226.         mov ax,sinus_pt        ; gestion trajectoire
  227.         add ax,8
  228.         and ax,2047
  229.         mov sinus_pt,ax
  230.  
  231.         lea bx,sinus           ; affichage balls
  232.         add bx,ax              ; 1
  233.         mov dx,bx
  234.         mov ax,[bx]
  235.         mov bx,2[bx]
  236.  
  237.         mov coord,ax
  238.         mov coord+2,bx
  239.  
  240.         call aff_ball
  241.  
  242.         add dx,32              ; 2
  243.         mov bx,dx
  244.         mov ax,[bx]
  245.         mov bx,2[bx]
  246.         mov coord+4,ax
  247.         mov coord+6,bx
  248.         call aff_ball
  249.  
  250.         add dx,32              ; 3
  251.         mov bx,dx
  252.         mov ax,[bx]
  253.         mov bx,2[bx]
  254.         mov coord+8,ax
  255.         mov coord+10,bx
  256.         call aff_ball
  257.  
  258.         add dx,32              ; 4
  259.         mov bx,dx
  260.         mov ax,[bx]
  261.         mov bx,2[bx]
  262.         mov coord+12,ax
  263.         mov coord+14,bx
  264.         call aff_ball
  265.  
  266.         add dx,32              ; 5
  267.         mov bx,dx
  268.         mov ax,[bx]
  269.         mov bx,2[bx]
  270.         mov coord+16,ax
  271.         mov coord+18,bx
  272.         call aff_ball
  273.  
  274.         add dx,32              ; 6
  275.         mov bx,dx
  276.         mov ax,[bx]
  277.         mov bx,2[bx]
  278.         mov coord+20,ax
  279.         mov coord+22,bx
  280.         call aff_ball
  281.  
  282.         add dx,32              ; 7
  283.         mov bx,dx
  284.         mov ax,[bx]
  285.         mov bx,2[bx]
  286.         mov coord+24,ax
  287.         mov coord+26,bx
  288.         call aff_ball
  289.  
  290.  
  291.  ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  292.         in    al,60h     ; attend Space Bar pour arreter
  293.         cmp   al,39h
  294.         jne   main
  295.  
  296.  ;************************************
  297.  
  298.         cli
  299.  
  300.         mov             cx,cs
  301.         mov             ds,cx
  302.         lds dx,dword ptr timer    ;ds = donnees
  303.         mov             ax,2508h
  304.         int             21h       ; replace ancienne Timer rout.
  305.         mov             ds,cx
  306.  
  307.         mov             al,182    ; reprogramme Timer à 18.2 Hz
  308.         out             43h,al
  309.         mov             al,0ffh   ; 1193180/18.2 = 65535 = $ffff
  310.         out             40h,al
  311.         out             40h,al
  312.  
  313.         mov             al,00000000b
  314.         out             021h,al    ; autorise all interrupts
  315.         mov             al,00000000b
  316.         out             0a1h,al
  317.  
  318.         sti
  319.  
  320.         mov             ax,0003h ; Mode Text 80x25
  321.         int             10h
  322.  
  323.  
  324.         mov             ax,4c00h ; Exit
  325.         int             21h
  326.  
  327. ;***********************************************************
  328.  
  329. ;---------------------------------
  330. ; sprite
  331. aff_ball        proc near
  332.  
  333.  push ds
  334.  
  335.  xor ch,ch
  336.  
  337.  mov si,seg ball
  338.  mov ds,si
  339.  mov si,offset ball
  340.  
  341.  mov di,0a000h
  342.  mov es,di
  343.  
  344.  mov cl,6
  345.  sal bx,cl
  346.  mov di,bx
  347.  sal bx,1
  348.  sal bx,1
  349.  add di,bx
  350.  add di,ax  ;screen base + x + y*320
  351.  cld
  352.  
  353.  include c:\masm\data\ball.asm
  354.  
  355.  pop ds
  356.  
  357.  ret
  358. aff_ball        endp
  359.  
  360. clr_ball        proc near
  361.  
  362.  push ds
  363.  
  364.  xor ch,ch
  365.  
  366.  mov si,seg back
  367.  mov ds,si
  368.  mov si,offset back
  369.  
  370.  mov di,0a000h
  371.  mov es,di
  372.  
  373.  mov cl,6
  374.  sal bx,cl
  375.  mov di,bx
  376.  sal bx,1
  377.  sal bx,1
  378.  add di,bx
  379.  add di,ax  ;screen base + x + y*320
  380.  
  381.  add si,di
  382.  
  383.  cld
  384.  
  385.  
  386.  include c:\masm\data\ball.fsm
  387.  
  388.  pop ds
  389.  
  390.  ret
  391. clr_ball        endp
  392. ;---------------------------------
  393.  
  394.  
  395.  
  396. ; port 3da bit 3
  397. wait_vbl        proc    near    ; pour attendre la VBL
  398.         mov     dx,03DAh
  399.         in      al,dx
  400.         and     al,8h
  401.         test    al,8h
  402.         jz      V_Ready
  403. V_Not_Ready:
  404.         in      al,dx
  405.         and     al,8h
  406.         test    al,8h
  407.         jz      V_Not_Ready
  408. V_Ready:
  409.         in      al,dx
  410.         and     al,8h
  411.         test    al,8h
  412.         jz      V_Ready
  413.         ret
  414.  
  415. wait_vbl        endp
  416.  
  417. ; port 3da bit 0
  418. wait_hbl proc near       ;attend HBL
  419.  
  420.         mov     dx,3dah
  421. hbl:
  422.         in      al,dx
  423.         and     al,1
  424.         test    al,1
  425.         jne     hbl
  426.  
  427. hbl2:
  428.         in      al,dx
  429.         and     al,1
  430.         test    al,0
  431.         jne     hbl2
  432.  
  433.         ret
  434.  
  435. wait_hbl endp
  436.  
  437. ;****************************************************************
  438.  
  439. raster proc near    ; Interruption Timer
  440.  
  441.        push dx
  442.        push ax
  443.        push si
  444.        push ds
  445.  
  446.        mov si,cs
  447.        mov ds,si
  448.  
  449.        mov dx,3c8h
  450.        xor al,al
  451.        out dx,al
  452.        inc dx
  453.        mov si,pok
  454.        outsb
  455.        outsb
  456.        outsb
  457.        mov pok,si
  458.  
  459.        mov al,20h   ; EOI
  460.        out 20h,al
  461.  
  462.        pop ds
  463.        pop si
  464.        pop ax
  465.        pop dx
  466.  
  467.        iret
  468.  
  469. raster endp
  470.  
  471. pok dw (?)
  472. ;****************************************************************
  473.  
  474. ;************** Section Data ****************
  475. colors_table:
  476.  rept 300
  477.   db 0,0,0
  478.  endm
  479.  
  480. colors_table2:
  481.  rept 300
  482.   db 0,0,0
  483.  endm
  484.  
  485. rolo1:
  486.  ;rouleaux de  30 lignes
  487.  
  488.  ;bleu
  489.  db 0,0,0,0,0,4,0,0,8,0,0,12,0,0,16,0,0,20,0,0,24,0,0,28,0,0,32
  490.  db 0,0,36,0,0,40,0,0,44,0,0,48,0,0,52,0,0,56,0,0,60,0,4,56
  491.  db 0,4,52,0,4,48,0,4,44,0,4,40,0,4,36,0,4,32,0,4,28,0,4,24
  492.  db 0,4,20,0,4,16,0,4,12,0,4,8,0,4,4
  493.  
  494.  ;vert
  495.  db 0,0,0,0,4,0,0,8,0,0,12,0,0,16,0,0,20,0,0,24,0,0,28,0,0,32,0
  496.  db 0,36,0,0,40,0,0,44,0,0,48,0,0,52,0,0,56,0,0,60,0,4,56,0
  497.  db 4,52,0,4,48,0,4,44,0,4,40,0,4,36,0,4,32,0,4,28,0,4,24,0
  498.  db 4,20,0,4,16,0,4,12,0,4,8,0,4,4,0
  499.  
  500.  ;rouge
  501.  db 0,0,0,4,0,0,8,0,0,12,0,0,16,0,0,20,0,0,24,0,0,28,0,0,32,0,0
  502.  db 36,0,0,40,0,0,44,0,0,48,0,0,52,0,0,56,0,0,60,0,0,56,0,4
  503.  db 52,0,4,48,0,4,44,0,4,40,0,4,36,0,4,32,0,4,28,0,4,24,0,4
  504.  db 20,0,4,16,0,4,12,0,4,8,0,4,4,0,4
  505.  
  506.  ;rose
  507.  db 0,0,0,4,0,4,8,0,8,12,0,12,16,0,16,20,0,20,24,0,24,28,0,28,32,0,32
  508.  db 36,0,36,40,0,40,44,0,44,48,0,48,52,0,52,56,0,56,60,0,60,56,4,56
  509.  db 52,4,52,48,4,48,44,4,44,40,4,40,36,4,36,32,4,32,28,4,28,24,4,24
  510.  db 20,4,20,16,4,16,12,4,12,8,4,8,4,4,4
  511.  
  512.  ;jaune
  513.  db 0,0,0,4,4,0,8,8,0,12,12,0,16,16,0,20,20,0,24,24,0,28,28,0,32,32,0
  514.  db 36,36,0,40,40,0,44,44,0,48,48,0,52,52,0,56,56,0,60,60,0,56,56,4
  515.  db 52,52,4,48,48,4,44,44,4,40,40,4,36,36,4,32,32,4,28,28,4,24,24,4
  516.  db 20,20,4,16,16,4,12,12,4,8,8,4,4,4,4
  517.  
  518. rolo_sin:
  519.  include c:\masm\data\rolo.sin
  520. rolo_pt dw 0
  521.  
  522. sinus:
  523.  include c:\masm\data\sinus.dat
  524. sinus_pt dw 0
  525. coord dw 2*4 dup(0)
  526.  
  527. fond:
  528.  rept 30
  529.  db  0,0,0
  530.  endm
  531.  db 0,0,0,0,0,0,0,0,1,0,0,1,0,0,2,0,0,2,0,0,3,0,0,3,0,0,4,0,0,4
  532.  db 0,0,5,0,0,5,0,0,6,0,0,6,0,0,7,0,0,7,0,0,8,0,0,8,0,0,9,0,0,9
  533.  db 0,0,10,0,0,10,0,0,11,0,0,11,0,0,12,0,0,12,0,0,13,0,0,13
  534.  db 0,0,14,0,0,14,0,0,15,0,0,15,0,0,16,0,0,16,0,0,17,0,0,18
  535.  db 0,0,19,0,0,19,0,0,20,0,0,20,0,0,21,0,0,21,0,0,22,0,0,22
  536.  db 0,0,23,0,0,23,0,0,24,0,0,24,0,0,25,0,0,25,0,0,26,0,0,26
  537.  db 0,0,27,0,0,27,0,0,28,0,0,28,0,0,29,0,0,29,0,0,30,0,0,30
  538.  db 0,0,31,0,0,31,0,0,32,0,0,32,0,0,33,0,0,33,0,0,34,0,0,34
  539.  db 0,0,35,0,0,35,0,0,36,0,0,36,0,0,37,0,0,37,0,0,38,0,0,38
  540.  db 0,0,39,0,0,39,0,0,40,0,0,40,0,0,41,0,0,41,0,0,42,0,0,42
  541.  db 0,0,43,0,0,43,0,0,44,0,0,44,0,0,45,0,0,45,0,0,46,0,0,46
  542.  db 0,0,47,0,0,47,0,0,48,0,0,48,0,0,49,0,0,49,0,0,50,0,0,50
  543.  db 0,0,51,0,0,51,0,0,52,0,0,52,0,0,53,0,0,53,0,0,54,0,0,54
  544.  db 0,0,55,0,0,55,0,0,56,0,0,56,0,0,57,0,0,57,0,0,58,0,0,58
  545.  db 0,0,59,0,0,59,0,0,60,0,0,60,0,0,61,0,0,61,0,0,62,0,0,62
  546.  db 0,0,63,0,0,63
  547.  rept 80
  548.  db 0,0,0
  549.  endm
  550.  
  551. timer dw (?),(?)     ; sauvegarde Segment et Offset routine Timer
  552.  
  553. image db 'pcteam.map','$'
  554.  
  555. palet:
  556.  include c:\masm\data\pcteam.pal
  557.  
  558. ;*******************************************
  559.  
  560.  
  561. code    ends
  562.         end     maitre
  563.